{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "3f3d52ee",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "datetime.datetime(2021, 9, 12, 20, 16, 45, 752253)"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 从python基础库（标准库中）找到datetime模块\n",
    "from datetime import datetime\n",
    "datetime.today()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fe2f4ab8",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "时间是奇数，时间在odds的数据中\n"
     ]
    }
   ],
   "source": [
    "# 课本代码（项目一，从奇数中选择对应的时间节点）\n",
    "\n",
    "\n",
    "odds =[1,3,5,7,9,11,13,15,17,19,21,23,25,27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59]\n",
    "\n",
    "right_this_minute = datetime.today().minute\n",
    "\n",
    "if right_this_minute in odds:\n",
    "    print(\"时间是奇数，时间在odds的数据中\")\n",
    "else:\n",
    "    print(\"not an odd minute\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4bd0fab4",
   "metadata": {},
   "source": [
    "##  认识变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b3552810",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> 5+5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c56e061f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "60"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    ">>> 100-20*2"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ef20f532",
   "metadata": {},
   "source": [
    "##  if else"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3931821a",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'today' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-5-31e494c5f897>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mif\u001b[0m \u001b[0mtoday\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"sunday\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"great!\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32melif\u001b[0m \u001b[0mtoday\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"monday\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0mcondition\u001b[0m \u001b[1;33m==\u001b[0m \u001b[1;34m\"Headache\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m         \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"NOT rest.\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mNameError\u001b[0m: name 'today' is not defined"
     ]
    }
   ],
   "source": [
    "if today == \"sunday\":\n",
    "    print(\"great!\")\n",
    "elif today == \"monday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"NOT rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"up, up, up.\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "006e957a",
   "metadata": {},
   "source": [
    "## for+range"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "463e3ab0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[8, 6, 4, 2]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "range(5)\n",
    "\n",
    "list(range(3))\n",
    "\n",
    "list(range(3,8))\n",
    "\n",
    "list(range(0,8,2))\n",
    "\n",
    "list(range(8,0,-2))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d3636a9c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "90b3168d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56cf8970",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
